<!DOCTYPE html>
<html lang="zh-CN">
<head>
	<%layout("/WEB-INF/view/common/inc/admin_head.html",{title:'', styles:'bootstrap,font-awesome,animate,style,bootstrap-table,layui-date,layui'}){}%>
</head>

<body>

<div class="wrapper wrapper-content">
	<div class="row">
		<div class="col-sm-12">
			<!-- START 右侧数据 -->
			<div class="ibox float-e-margins" style="margin-bottom: 0px;">
				<div class="ibox-content" style="padding:15px 20px 0px 20px;">
					<form id="search-form" role="form" class="form-inline">
						<div class="form-group">
							<label>柜号:</label>
							<input type="text" id="stockNo" name="stockNo" placeholder="请输入柜号" class="form-control">
						</div>
						<div class="form-group">
							<label>SKU:</label>
							<input type="text" id="stockSku" name="stockSku" placeholder="请输入SKU" class="form-control">
						</div>
						<a class="search-btn btn btn-success" style="margin-bottom: 0px;">查询</a>
					</form>
				</div>
			</div>
			<div id="toolbar" class="btn-group" style="margin-bottom:5px;">
				<button  class="export-btn layui-btn  layui-btn-sm" style="margin-left: -2px">
					<i class="fa fa-download" aria-hidden="true"></i> 导出当前数据
				</button>
				<button  class="layui-btn  layui-btn-sm" >
					<i class="fa fa-download"></i>
					<a href="/excel/海外仓模板.xlsx" style="color: white" download>模板下载</a>
				</button>
				<button  class="layui-btn layui-btn-sm import-btn" style="margin-left: -2px"  id="import-btn"  name="import-btn">
					<i class="layui-icon"></i>导入海外仓库存
				</button>
			</div>
			<!-- START 操作按钮 -->
			<!-- START 数据表格 -->
			<table id="stockTable"
				   data-toolbar="#toolbar"
				   data-side-pagination="server"
				   data-pagination="true"
				   data-resizable="true"
				   data-side-pagination="server"
				   data-url="/sea/physical/stockProduce/findByCnd.do"
				   data-page-size="15">
			</table>
			<!-- END 数据表格 -->

			<!-- END 右侧数据 -->
		</div>
	</div>
</div>

<%layout("/WEB-INF/view/common/inc/admin_js.html",{modules:'jquery,bootstrap,bootstrap-table,bootstrap-table-zh-CN,layer,laydate,layui,upload'}){}%>
<script>
	layui.use('upload', function(){
		var upload = layui.upload;
		upload.render({
			elem: '#import-btn', //绑定元素,
			accept:'file',
			url: '/sea/physical/stockProduce/import/', //上传接口

			before:function () {
				layer.load(1, {
					shade: [0.1,'#fff'] //0.1透明度的白色背景
				});
			}
			,done: function(data){
				if( data.ok ){
					layer.msg(data.msg,{icon: 1,time: 1500},function(){
						//刷新页面
						$stockTable.bootstrapTable('refresh');
						layer.closeAll();
					});
				}else{
					layer.msg(data.msg,{icon: 0,time: 5000},function () {
						layer.closeAll();
					});

				}
			}
			,error: function(){
				//请求异常回调
				layer.closeAll();
			}
		});
	});
    var $stockTable = $('#stockTable'),selections=[];
    $(function(){

        //START 表格配置
        $stockTable.bootstrapTable({
            columns: [
                {
                    title: '柜号',
                    field: 'stockNo',
                    align: 'center',
                    valign: 'middle'
                },
				{
					title: '仓库',
					field: 'stockWareName',
					align: 'center',
					valign: 'middle'
				},
				{
					title: 'shipmentId',
					field: 'stockShipmentId',
					align: 'center',
					valign: 'middle'
				},
				{
					title: '渠道',
					field: 'stockChannelName',
					align: 'center',
					valign: 'middle'
				},
                {
                    title: 'SKU',
                    field: 'stockSku',
                    align: 'center',
                    valign: 'middle'
                },{
					title: '商品名称',
					field: 'productName',
					align: 'center',
					valign: 'middle'
				},{
					title: '颜色',
					field: 'productColorName',
					align: 'center',
					valign: 'middle'
				},{
					title: '尺码(INCH)',
					field: 'productInch',
					align: 'center',
					valign: 'middle'
				},{
					title: '尺码(CM)',
					field: 'productCm',
					align: 'center',
					valign: 'middle'
				},{
					title: '剩余量',
					field: 'stockNumber',
					align: 'left',
					valign: 'middle'
				},{
					title: '占用量',
					field: 'stockUseNumber',
					align: 'left',
					valign: 'middle'
				}
            ],
            onLoadSuccess : function() {

            }
        });
        //END 表格配置

        //表格高度自适应
        $(window).resize(function () {
			$stockTable.bootstrapTable('resetView', {
                height: getHeight()
            });
        });
    });

	// 条件查询
	$('.search-btn').on('click',function () {
		$stockTable.bootstrapTable('refresh', { url:'${ctxPath}/sea/physical/stockProduce/findByCnd.do?'+$('#search-form').serialize() });
	});
	$(".export-btn").click(function () {
		window.location.href='/sea/physical/stockProduce/export.do?'+$('#search-form').serialize();
	});
</script>
</body>
</html>
